#include <stdio.h>
#include <stdlib.h>

int main(int argc, char *argv[])
{
	if(argc<1){
		puts("Usage: splash rgb24_image_file_name. ");
		puts("Generage rgb24_image by `IMGtoRGB24'.");
		exit(1);
	}
	
	FILE *in = fopen(argv[1], "r");
	FILE *out = fopen("/dev/fb0", "w");
	if(in==0){
		perror(argv[1]);
		exit(1);
	}
	if(out==0){
		perror("/dev/fb0");
		exit(1);
	}
	int i;
	int r,g,b;
	int p;
	for(i=0; i<240*320; i++){
		r=fgetc(in)&0xF8;
		g=fgetc(in)&0xF8;
		b=fgetc(in)&0xF8;
		p=(r>>3)|(g<<2)|(b<<7);
		fputc(p&0xFF, out);fputc(p>>8, out);
		
	}
	fclose(in);
	fclose(out);
	return 0;
}
